<?php

namespace Topxia\Service\Kuke\Dao\Impl;

use Topxia\Service\Common\BaseDao;
use Topxia\Service\Kuke\Dao\LessonLearnDao;

class LessonLearnDaoImpl extends BaseDao implements LessonLearnDao
{
    protected $table = 'course_lesson_learn';

    public function getxueba($limit)
    {
        $sql = "SELECT user.id, user.nickname, user.mediumAvatar, count({$this->table}.id) as num FROM {$this->table},user WHERE {$this->table}.status = 'finished' and {$this->table}.userid = user.id group by {$this->table}.userId order by num desc";
        // $sql = "SELECT user.id, user.nickname, user.mediumAvatar, count({$this->table}.id) as num FROM {$this->table},user WHERE {$this->table}.userid = user.id group by {$this->table}.userId order by num desc";
		if ($limit) $sql .= ' limit '.$limit;
        return $this->getConnection()->fetchAll($sql) ? : null;
    }
}